home *** CD-ROM | disk | FTP | other *** search
/ George Foreman's Interac…ng, Barbeque & Rotisserie / George Foreman's Interactive Guide to Grilling, Barbeque, and Rotisserie.iso / j / treemenu.js < prev   
Text File  |  2002-10-22  |  13KB  |  387 lines

  1. var pararray = new Array();        //holds flag of bar to display.
  2. var targetIFrame='toc';            //holds name of targetted IFrame Object.
  3. var bookTitle='';                //holds title of book to be displayed.
  4. var bookIcon='';                //holds Icon of book to be displayed.
  5. var imgPath='';                    //holds Path string of images directory.
  6. var valueAddedWindow;
  7. var curFocus=0;
  8.  
  9. function showPopup(url) {
  10.     if (!valueAddedWindow || valueAddedWindow.closed) {
  11.         valueAddedWindow = window.open(url,'f001007pagevalueaddedmedia_window','height=540,width=760,resizable=1,scrollbars=yes,top=10,left=10');
  12.     } else {
  13.         valueAddedWindow.focus();
  14.     }
  15. }
  16.  
  17. function treeExpand(n) {
  18.     curFocus=n
  19.     menuitems[n][3]=true;
  20.     setTimeout("treeDisplay()", 1);
  21. }
  22.  
  23. function treeCollapse(n) {
  24.     curFocus=n
  25.     menuitems[n][3]=false;
  26.     setTimeout("treeDisplay()", 1);
  27. }
  28.  
  29. function loadPage(link)
  30. {
  31.  
  32.     var temp1= 'pagenumber=';
  33.     var temp2 = '&p=';
  34.  
  35.     var indexofpagenumber = link.indexOf(temp1);
  36.     if(indexofpagenumber==-1) {
  37.         return;
  38.     }
  39.     var indexofpointer = link.lastIndexOf(temp2);
  40.     //alert(indexofpagenumber);
  41.     //alert(indexofpointer);
  42.     var pagenumber = link.substring(indexofpagenumber+ temp1.length,indexofpointer );
  43.     var pointer = link.substring(indexofpointer+ temp2.length,link.length );
  44.     if(pointer=='') {
  45.         link = pagenumber;
  46.     } else {
  47.     link = pagenumber+'$'+pointer;
  48.     }
  49.     //alert(link);
  50.  
  51.     if (targetIFrame=='view') {
  52.         parent.opener.fromTOC(link);
  53.     }
  54.  
  55.     else {
  56.         parent.fromTOC(link);
  57.         }
  58.     }
  59.  
  60.  
  61. function treeCreate(strArray) {
  62.     imgPath    ='../../i/';
  63.     //alert(imgPath);
  64.     var curCnt;
  65.     for (cnt=0;cnt<menuitems.length;cnt++)
  66.     {
  67.         //if (cnt==curFocus)
  68.         //    alert("Create Focus "+curFocus);
  69.  
  70.         curCnt=cnt;
  71.  
  72.         // the text that appears in TOC
  73.         var actualDisplay = menuitems[curCnt][1]
  74.  
  75.         // the text that appears in the alt message of the each TOC link
  76.         var altDisplay = menuitems[curCnt][1]
  77.  
  78.         var strMenu='<tr valign="top"><td valign="top" nowrap>'
  79.  
  80.         if (cnt==curFocus)
  81.             strMenu='<tr valign="top"><td valign="top" nowrap><a style="cursor: pointer; cursor: hand;" name="focusPointer"></a>'
  82.  
  83.         for (i=0; i<menuitems[cnt][0]; i++) {
  84.         if (pararray[cnt].substring(i,i+1)=='0')
  85.             strMenu+='<img src="' + imgPath + '9.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">';
  86.         else
  87.             strMenu+='<img src="' + imgPath + '1.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">';
  88.             }
  89.  
  90.  
  91.         if (cnt<menuitems.length-1 && menuitems[cnt][0]<menuitems[cnt+1][0])
  92.         {
  93.             var isChanged = false;
  94.  
  95.             var folderPath = imgPath + '5.gif';
  96.             var isVideo = altDisplay.indexOf('<videoelement>');
  97.             if(isVideo!=-1) {
  98.                 folderPath = imgPath + 'DXReaderVideo.png';
  99.                 isChanged = true;
  100.             }
  101.  
  102.  
  103.             var isVideo = altDisplay.indexOf('<audioelement>');
  104.             if(isVideo!=-1) {
  105.                 folderPath = imgPath + 'DXReaderAudio.png';
  106.                 isChanged = true;
  107.             }
  108.  
  109.  
  110.             var isVideo = altDisplay.indexOf('<audioelement>');
  111.             if(isVideo!=-1) {
  112.                 folderPath = imgPath + 'DXReaderAudio.png';
  113.                 isChanged = true;
  114.             }
  115.  
  116.  
  117.             var isFigures = altDisplay.indexOf('<figureelement>');
  118.             if(isFigures!=-1) {
  119.                 folderPath = imgPath + 'DXReaderFigures.png';
  120.                 isChanged = true;
  121.             }
  122.  
  123.  
  124.             var isFeatures = altDisplay.indexOf('<featureelement>');
  125.             if(isFeatures!=-1) {
  126.                 folderPath = imgPath + 'DXReaderFeatures.png';
  127.                 isChanged = true;
  128.             }
  129.  
  130.  
  131.             var isMap = altDisplay.indexOf('<mapelement>');
  132.             if(isMap!=-1) {
  133.                 folderPath = imgPath + 'DXReaderMaps.png';
  134.                 isChanged = true;
  135.             }
  136.  
  137.  
  138.             var isChronologies = altDisplay.indexOf('<chronologyelement>');
  139.             if(isChronologies!=-1) {
  140.                 folderPath = imgPath + 'DXReaderChronologies.png';
  141.                 isChanged = true;
  142.             }
  143.  
  144.  
  145.             var isInteractiveMaps = altDisplay.indexOf('<interactivemapyelement>');
  146.             if(isInteractiveMaps!=-1) {
  147.                 folderPath = imgPath + 'DXReaderInteractiveMaps.png';
  148.                 isChanged = true;
  149.             }
  150.  
  151.  
  152.             var isImages = altDisplay.indexOf('<imageselement>');
  153.             if(isImages!=-1) {
  154.                 folderPath = imgPath + 'DXReaderImages.png';
  155.                 isChanged = true;
  156.             }
  157.  
  158.             var isLives = altDisplay.indexOf('<liveselement>');
  159.             if(isLives!=-1) {
  160.                 folderPath = imgPath + 'American Lives.png';
  161.                 isChanged = true;
  162.             }
  163.  
  164.             var mappingPast = altDisplay.indexOf('<mappingpast>');
  165.             if(mappingPast!=-1) {
  166.                 folderPath = imgPath + 'Mapping the Past.png';
  167.                 isChanged = true;
  168.             }
  169.  
  170.             var reviewingpast = altDisplay.indexOf('<reviewingpast>');
  171.             if(reviewingpast!=-1) {
  172.                 folderPath = imgPath + 'Re-Viewing the Past.png';
  173.                 isChanged = true;
  174.             }
  175.  
  176.  
  177.             var milestones = altDisplay.indexOf('<milestones>');
  178.             if(milestones!=-1) {
  179.                 folderPath = imgPath + 'Milestone.png';
  180.                 isChanged = true;
  181.             }
  182.  
  183.  
  184.  
  185.             if (menuitems[cnt][3])
  186.             {
  187.                 strMenu+='<a style="cursor: pointer; cursor: hand;" href="javascript: parent.toc.treeCollapse('+cnt+')">'
  188.                 if (pararray[cnt].substring(menuitems[cnt][0],menuitems[cnt][0]+1) == '1')
  189.                     strMenu+='<img src="' + imgPath + '11.gif"  align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  190.                 else
  191.                     strMenu+='<img src="' + imgPath + '3.gif"  align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  192.  
  193.                 if(isChanged) {
  194.                     strMenu+='<img src="' +  folderPath  + '" align="left" border="0" vspace="0" hspace="0" width="18" height="18"></a>'
  195.                 } else {
  196.                     strMenu+='<img src="' + imgPath + '6.gif"  align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  197.                 }
  198.  
  199.             }
  200.             else
  201.             {
  202.                 strMenu+='<a style="cursor: pointer; cursor: hand;" href="javascript: parent.toc.treeExpand('+cnt+')">'
  203.                 if (pararray[cnt].substring(menuitems[cnt][0],menuitems[cnt][0]+1) == '1')
  204.                     strMenu+='<img src="' + imgPath + '12.gif"  align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  205.                 else
  206.                     strMenu+='<img src="' + imgPath + '4.gif"  align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  207.  
  208.                 if(isChanged) {
  209.                     strMenu+='<img src="' +  folderPath  + '" align="left" border="0" vspace="0" hspace="0" width="18" height="18"></a>'
  210.                 } else {
  211.                     strMenu+='<img src="' + imgPath + '5.gif"  align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  212.                 }
  213.  
  214.                 while(cnt<menuitems.length-1 && menuitems[curCnt][0]<menuitems[cnt+1][0])
  215.                     cnt++;
  216.             }
  217.         }
  218.         else
  219.         {
  220.             if (cnt==999) {alert(pararray[cnt].substring(menuitems[cnt][0],menuitems[cnt][0]+1));alert(pararray[cnt]);}
  221.             if (pararray[cnt].substring(menuitems[cnt][0],menuitems[cnt][0]+1) == '1')
  222.                 strMenu+='<img src="' + imgPath + '10.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  223.             else
  224.                 strMenu+='<img src="' + imgPath + '2.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  225.  
  226.             strMenu+='<img src="' + imgPath + '7.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
  227.         }
  228.  
  229.  
  230.         // display only 40 charactres and full text in alt message
  231.         // this condition is to be applied to views only
  232.         if (targetIFrame=='view') {
  233.             if(actualDisplay.length > 40) {
  234.                 var temp = actualDisplay.substring(0,40);
  235.                 //alert(temp);
  236.                 var index = temp.lastIndexOf('&');
  237.                 var index1 = temp.indexOf(';',index);
  238.  
  239.                 if(index!=-1) {
  240.  
  241.                 if(index1 == -1){
  242.                     //alert('adding remaining part');
  243.                     var index2 = actualDisplay.indexOf(';',index);
  244.                     //alert(index2);
  245.                     temp = temp.substring(0,index);
  246.                     temp = temp + actualDisplay.substring(index,index2);
  247.                     //alert(temp);
  248.                 }
  249.                 }
  250.  
  251.                 actualDisplay = temp+" ...";
  252.             }
  253.         }
  254.  
  255.         // if its link for video attach the icon for for video
  256.         var isVideo = altDisplay.indexOf('<video>');
  257.         if(isVideo!=-1) {
  258.             actualDisplay = '<img src="' +imgPath +'vi.png" border="0">' + actualDisplay;
  259.             altDisplay = altDisplay.substring(8,altDisplay.length);
  260.         }
  261.  
  262.         // if its link for audio attach the icon for for audio
  263.         var isAudio = altDisplay.indexOf('<a style="cursor: pointer; cursor: hand;"udio>');
  264.         if(isAudio!=-1) {
  265.             actualDisplay = '<img src="' +imgPath +'au.png" border="0">' + actualDisplay;
  266.             altDisplay = altDisplay.substring(8,altDisplay.length);
  267.         }
  268.  
  269.         // if its link for animation attach the icon for for animation
  270.         var isAnimation = altDisplay.indexOf('<a style="cursor: pointer; cursor: hand;"nima>');
  271.         if(isAnimation!=-1) {
  272.             actualDisplay = '<img src="' +imgPath +'ani.png" border="0">' + actualDisplay;
  273.             altDisplay = altDisplay.substring(8,altDisplay.length);
  274.         }
  275.  
  276.         // if its link for quizes attach the icon for for quizes
  277.         var isQuize = altDisplay.indexOf('<quize>');
  278.         if(isQuize!=-1) {
  279.             actualDisplay = '<img src="' +imgPath +'qa.png" border="0">' + actualDisplay;
  280.             altDisplay = altDisplay.substring(8,altDisplay.length);
  281.         }
  282.  
  283.  
  284.         if (menuitems[curCnt][2] != '') {
  285.  
  286.             if(isVideo!=-1) {
  287.                 strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="' + menuitems[curCnt][2] + '\">'+actualDisplay+'</a>'
  288.             } else
  289.  
  290.             if(isAudio!=-1) {
  291.                 strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="' + menuitems[curCnt][2] + '\">'+actualDisplay+'</a>'
  292.             }else
  293.  
  294.             if(isAnimation!=-1) {
  295.                 strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="javascript:parent.toc.showPopup(\'' + menuitems[curCnt][2] + '\')">'+actualDisplay+'</a>'
  296.             }else
  297.  
  298.             if(isQuize!=-1) {
  299.                 strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="javascript:parent.toc.showPopup(\'' + menuitems[curCnt][2] + '\')">'+actualDisplay+'</a>'
  300.             }else
  301.  
  302.             strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="javascript:parent.toc.loadPage(\'' + menuitems[curCnt][2] + '\')">'+actualDisplay+'</a>'
  303.         }
  304.         else {
  305.             strMenu+='<a style="cursor: pointer; cursor: hand;">'+menuitems[curCnt][1]+'</a>'
  306.             //alert(strMenu);
  307.         }
  308.  
  309.  
  310.  
  311.  
  312.         strMenu+='</td></tr>'
  313.         strArray[strArray.length]=strMenu;
  314.         //alert(strMenu);
  315.  
  316.     }
  317.  
  318. }
  319.  
  320. function treeDisplay()
  321. {
  322.     var strArray=new Array();
  323.     var strHTML = '';
  324.  
  325.     if(top.os == 'Macintosh') {
  326.         strHTML ='<HTML><HEAD><script>function addFocus() { parent.tocdis.document.location.href="#focusPointer"; } </script><SCRIPT LANGUAGE="JavaScript" SRC="../../j/security.js"></SCRIPT><style>a {font-family: arial; font-size: 82%; text-decoration: none;}a:link {font-family: arial; font-size: 82%; text-decoration: none;}a:visited {font-family: arial; font-size: 82%; color: #ff0000; text-decoration: none;}a:hover {font-family: arial; font-size: 82%; color: #000000; font-weight: bold; text-decoration: underline;}</style></HEAD><BODY>';
  327.     } else {
  328.         strHTML ='<HTML><HEAD><script>function addFocus() { parent.tocdis.document.location.href="#focusPointer"; } </script><SCRIPT LANGUAGE="JavaScript" SRC="../../j/security.js"></SCRIPT><style>a {font-family: arial; font-size: 82%; text-decoration: none;}a:link {font-family: arial; font-size: 82%; text-decoration: none;}a:visited {font-family: arial; font-size: 82%; color: #ff0000; text-decoration: none;}a:hover {font-family: arial; font-size: 82%; color: #000000; font-weight: bold; text-decoration: underline;}</style></HEAD><BODY onload="addFocus()">';
  329.     }
  330.  
  331.  
  332.     strHTML+='<table cellspacing="0" cellpadding="0" border="0"><tr valign="top"><td nowrap class="btitle">'
  333.     fillIndentArray();
  334.     imgPath    ='../../i/';
  335.     var displayTitle = bookTitle.substring(3,bookTitle.length-4);
  336.  
  337.     if (bookIcon!='')
  338.         strHTML+='<img src="' + imgPath + bookIcon + '">'
  339.     strHTML+='<a style="cursor: pointer; cursor: hand;"  title="'+displayTitle+'">'+bookTitle + '</a></td></tr>'
  340.  
  341.     //creates HTML string for all nodes and adds to strHTML
  342.     treeCreate(strArray);
  343.     strHTML+=strArray.join(' ')
  344.     strHTML+='</table>'
  345.     strHTML+='</BODY></HTML>'
  346.     //alert(strHTML);
  347.  
  348.  
  349.     parent.tocdis.document.open();
  350.     parent.tocdis.document.write(strHTML);
  351.     parent.tocdis.document.close();
  352.     //document.getElementById("d1").innerHTML='';
  353.     //document.getElementById("d1").innerHTML=strHTML
  354. }
  355.  
  356. function bstr(xx,str)
  357. {
  358.     if (str.length>=xx)
  359.     {
  360.         if (str.length>xx)
  361.             return str.substring(0,xx);
  362.         else
  363.             return str.substring(0,xx-1) + '1';
  364.     }
  365.      else
  366.         return str.substring(0,str.length-1)+'1'+mystr('0',xx-str.length);
  367. }
  368.  
  369. function mystr(chval,numval)
  370. {
  371.     var k,stval;
  372.     stval='';
  373.     for (k=0;k<numval;k++)
  374.         stval=stval+'0';
  375.     return stval;
  376. }
  377.  
  378. function fillIndentArray(arr)
  379. {
  380.     var oldstr='00000';
  381.     var cnt;
  382.     for(cnt=menuitems.length-1;cnt>=0;cnt--)
  383.     {
  384.         pararray[cnt]=bstr(menuitems[cnt][0]+1,oldstr);
  385.         oldstr=pararray[cnt];
  386.     }
  387. }